function [img1, img2, img3, img4] = diff_JPEG2D(img, T)
    % DIFF_JPEG2D  calculate difference JPEG-2D array.
    if nargin < 2
        error('diff_JPEG2D:TooFewArg', 'Too few arguments.');
    end
    [M,N] = size(img);
    img1 = threshold(img(1:M-1,1:N-1)-img(1:M-1,2:N), T); %horizontal
    img2 = threshold(img(1:M-1,1:N-1)-img(2:M,1:N-1), T); %vertical
    img3 = threshold(img(1:M-1,1:N-1)-img(2:M,2:N), T); %main diagonal
    img4 = threshold(img(2:M,1:N-1)-img(1:M-1,2:N), T); %minor diagonal
end
